<?php
// +----------------------------
// | Created by PhpStorm
// +----------------------------
// | Author: YnnSon
// +----------------------------
namespace app\api\controller\v1;

use app\api\model\Subscribe as SubscribeModel;
use app\api\validate\ParameterMustBePositiveInteger;
use app\lib\exception\SuccessMessage;
use think\Request;

class Subscribe extends BaseController
{
    /**
     * @Desc 获取预约时间段及剩余数量列表
     * @return array
     */
    public function getList()
    {
        $param = Request::instance()->param();
        return SubscribeModel::getList($param);
    }

    /**
     * @Desc 取消/未通过订单恢复预约数量
     *
     * @param $id
     *
     * @return SuccessMessage
     */
    public function restoreSubscribeNumber($id)
    {
        (new ParameterMustBePositiveInteger())->scene('id')->goCheck();
        SubscribeModel::restoreSubscribeNumber($id);
        return new SuccessMessage();
    }
}